package com.example.image

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

object GlideUtils {
    //普通图片
    fun loadImage(context:Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .error(R.drawable.ic_yu_icon)
            .placeholder(R.drawable.ic_yu_icon)
            .skipMemoryCache(false)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .into(imageView)
    }
    //圆形图片
    fun loadCircleImage(context:Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .error(R.drawable.ic_yu_icon)
            .placeholder(R.drawable.ic_yu_icon)
            .skipMemoryCache(false)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .circleCrop()
            .into(imageView)
    }
    //圆角图片
    fun loadCornerImage(context:Context,url:String,imageView: ImageView,radius:Int){
        Glide.with(context)
            .load(url)
            .error(R.drawable.ic_yu_icon)
            .placeholder(R.drawable.ic_yu_icon)
            .skipMemoryCache(false)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .transform(RoundedCorners(radius))
            .into(imageView)
    }
}